/*
215 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
What is the sum of the digits of the number 21000?

Anser:1366
Time:59.184µs
*/
package main

import (
	"fmt"
	"time"
)

func main() {
	tstart := time.Now()
	s := make([]int, 1)
	s[0] = 1
	for i := 0; i < 1e3; i++ {
		carry := 0
		for j, count := 0, len(s); j < count; j++ {
			s[j] = 2*s[j] + carry
			carry, s[j] = s[j]/1e10, s[j]%1e10
		}
		if carry > 0 {
			s = append(s, carry)
		}
	}
	sum := 0
	for _, v := range s {
		for v != 0 {
			sum += v % 10
			v /= 10
		}
	}
	fmt.Println(sum)

	tend := time.Now()
	fmt.Println(tend.Sub(tstart))
}
